﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataPackageScheme" @search="()=>{getTableDataPackageScheme();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Name_FormItem" prop="Name" :label="$t('message.autotrans._Model_PackageScheme_Name')">
            <el-input v-model="searchDataPackageScheme.Name" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Code_FormItem" prop="Code" :label="$t('message.autotrans._Model_PackageScheme_Code')">
            <el-input v-model="searchDataPackageScheme.Code" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_PackageScheme_ProductId')">
            <el-input v-model="searchDataPackageScheme.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductName_FormItem" prop="ProductName" :label="$t('message.autotrans._Model_PackageScheme_ProductName')">
            <el-input v-model="searchDataPackageScheme.ProductName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Rules_FormItem" prop="Rules" :label="$t('message.autotrans._Model_PackageScheme_Rules')">
            <el-input v-model="searchDataPackageScheme.Rules" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Qty_FormItem" prop="Qty" :label="$t('message.autotrans._Model_PackageScheme_Qty')">
            <el-input v-model="searchDataPackageScheme.Qty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EnablePrint_FormItem" prop="EnablePrint" :label="$t('message.autotrans._Model_PackageScheme_EnablePrint')">
            <el-select v-model="searchDataPackageScheme.EnablePrint" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="SerialNumber_FormItem" prop="SerialNumber" :label="$t('message.autotrans._Model_PackageScheme_SerialNumber')">
            <el-input v-model="searchDataPackageScheme.SerialNumber" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_PackageScheme_CreateTime')">
            <el-date-picker v-model="searchDataPackageScheme.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_PackageScheme_UpdateTime')">
            <el-date-picker v-model="searchDataPackageScheme.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_PackageScheme_CreateBy')">
            <el-input v-model="searchDataPackageScheme.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_PackageScheme_UpdateBy')">
            <el-input v-model="searchDataPackageScheme.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/PackageManagement/PackageScheme/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/PackageManagement/PackageScheme/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/PackageManagement/PackageScheme/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/PackageManagement/PackageScheme/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/PackageManagement/PackageScheme/PackageSchemeExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefPackageScheme" v-bind="tableDataPackageScheme">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/PackageManagement/PackageScheme/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/PackageManagement/PackageScheme/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/PackageManagement/PackageScheme/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PagePackageManagementPackageSchemeIndex;true;Digitalmes.PackageManagement.Controllers;PackageScheme">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { packageschemeApi } from '/@/api/packagemanagement/packagescheme';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const statePackageScheme = reactive({
    
});

const searchDataPackageScheme = ref({
        Name: '',
        Code: '',
        ProductId: null,
        ProductName: '',
        Rules: '',
        Qty: null,
        EnablePrint: undefined,
        SerialNumber: null,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefPackageScheme = ref();
const tableDataPackageScheme = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page名称'),key: 'PackageScheme_Name',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page编码'),key: 'PackageScheme_Code',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page装箱产品'),key: 'PackageScheme_ProductId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品名称'),key: 'PackageScheme_ProductName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page条码校验规则'),key: 'PackageScheme_Rules',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page装箱数量'),key: 'PackageScheme_Qty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page启用打标'),key: 'PackageScheme_EnablePrint',type: 'switch',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page流水号'),key: 'PackageScheme_SerialNumber',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'PackageScheme_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'PackageScheme_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'PackageScheme_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'PackageScheme_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataPackageScheme = () => {
    tableRefPackageScheme.value.doSearch(packageschemeApi().search, searchDataPackageScheme.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataPackageScheme)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataPackageScheme)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataPackageScheme)
};

// 删除
const onDelete = (row: any) => {
    packageschemeApi().delete([row.ID]).then(() => { getTableDataPackageScheme()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefPackageScheme.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      packageschemeApi().delete(selectedids).then(() => { getTableDataPackageScheme()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefPackageScheme.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataPackageScheme)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataPackageScheme)
};

const onExport = () => {
	const selected = tableRefPackageScheme.value.getSelectedRows();
	if (selected.length > 0) {
		packageschemeApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		packageschemeApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
        getTableDataPackageScheme();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

